<?php 
ob_start(); session_start();
require_once('config/setting.php');
if (!$_SESSION['userid'])
{
	header('location: login.php');
	
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<title>The Century - Admin Panel</title>
	<style>
        .topmenu{
            font-family:arial;
			font-weight:bold;
            font-size:16px;
            color:#FFFFFF;
            text-decoration:none;
        }
        .topmenu:hover{
            font-family:arial;
			font-weight:bold;
            font-size:16px;
            color:#FFFFFF;
            text-decoration:underline;
        }
    </style>
</head>
<body>

<?php 
	if($_POST['submitslot']){
		$warning = '';	
		$ntable = $_POST['ntable'];
		$ntime = $_POST['ntime'];
		$numcustomer = $_POST['numcustomer'];
		$datein = time();
		$result = mysql_query("SELECT * FROM tbl_slot where ntable='$ntable' and ntime='$ntime' ") or die (mysql_error());
        if($row = mysql_fetch_array($result)){		
			$warning = '<br>Warning!<br> Slot already exists please try again.<br>';
		}else{
			$warning = '<br>Slot successfuly created.</br>';
			mysql_query("insert into tbl_slot (id,ntable,ntime,numcustomer,dateposted) values ('','$ntable','$ntime','$numcustomer','$datein')") or die (mysql_error());
		}
	}
	
	if($_POST['deleteslot']){
		$warning = '';	
		$ntable = $_POST['ntable'];
		$ntime = $_POST['ntime'];
		$numcustomer = $_POST['numcustomer'];
		$datein = time();
		$result = mysql_query("SELECT * FROM tbl_slot where ntable='$ntable' and ntime='$ntime' ") or die (mysql_error());
		
        if($row = mysql_fetch_array($result)){	
			$id = $row["id"];
			$warning = '<br>Warning!<br> Slot successfuly deleted.<br>';
			
			mysql_query("delete from tbl_slot where id = '$id'") or die (mysql_error());
		}else{
			$warning = '<br>Slot does not exist. <br>Please Try Again.</br>';
			
		}
	}
?>


<table width="100%">
<div style="padding:10px; font-size:20px; font-family:verdana;"><span>THE CENTURY <span style="font-size:14px">Admin Panel</span></span></div>

<tr>
	<td style="width:100%; height:auto; ">
	  <table  style="width:100%; height:100%" border="0">
		<tr>
			<td style="background:#FF0000; height:71px;">
			   <div align="center">	
				   <table style="width:960px;" cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td style="height:42px; padding-top:15px"  >
								<table align="center" cellpadding="0" cellspacing="0" border="0">
									<tr>
										<td style="font-weight:bold; color:#FFFFFF">
                                        	<a href="view-customers.php" class="topmenu">View Customers</a> &nbsp;|&nbsp; 
											<a href="reports.php" class="topmenu">Reports</a> &nbsp;|&nbsp; 
                                            <a href="reservation.php" class="topmenu">Reservation</a> &nbsp;|&nbsp; 
                                            <a href="slots.php" class="topmenu">Slots</a> &nbsp;|&nbsp;  
                                            <a href="question.php" class="topmenu">Question</a> &nbsp;|&nbsp;  
                                            <a href="menus.php" class="topmenu">Menus</a> &nbsp;|&nbsp;  
                                            <a href="logout.php" class="topmenu">Logout</a> 
                                        </td>
									</tr>
								</table>							
                             </td>
						</tr>
					</table>			
				</div>			
              </td>
		</tr>	
	</table></td>
</tr>
<!--content-->
<tr>
	<td style="width:100%; padding-left:100px; font-family:arial; font-size:14px;  height:500px;" valign="top" align="center">
    	<table>
        	<tr>
            	<td bgcolor="#E8E8E8" style="padding:20px" valign="top">
                	<form name="sform" method="post">
                        <b>Create Slots</b><br><br>
                        Table Name:<br>
                        <select name="ntable" style="width:200px">
                            <option value="A">Table A : 2-4 persons</option>
                            <option value="B">Table B : 5-10 persons</option>
                            <option value="C">Table C : 11-16 persons</option>
                        </select><br><br>
                        Select Time:<br>
                        <select name="ntime" style="width:200px" >
                            <option>11:00AM</option>
                            <option>1:00PM</option>
                            <option>3:00PM</option>
                            <option>5:00PM</option>
                            <option>7:00PM</option>
                        </select><br>
                        
                        <span style="color:#F00"><?=$warning?></span><br>
                        <input name="submitslot" type="submit" style="height:40px; width:150px;" value="Submit Slot"><br>
                        <input name="deleteslot" type="submit" style="height:40px; width:150px;" value="Delete Slot">
					</form>                        
                </td>
                <td style="padding:20px; border:dotted 1px #FF0000" valign="top" align="left" >
                 <div style="width:500px"><span><b style="color:#F00">LIST OF SLOTS</b></span><br>		
				 <?php 
                    $result = mysql_query("SELECT * FROM tbl_slot ") or die (mysql_error());
                    while ($row = mysql_fetch_array($result)){
                        $table = $row['ntable'];
                        $time = $row['ntime'];
						if($table=='A'){
							$ncust = '2-4';
						}
						if($table=='B'){
							$ncust = '6-10';
						}
						if($table=='C'){
							$ncust = '11-16';
						}
						echo '
							<div style="width:120px; height:110px; border:solid 2px #FF0000; float:left; cursor:pointer; margin-right:15px; margin-top:15px;" align="center" onclick="location.href=\'reservation.php?step=3&table='.$table.'&time='.$time.'&nday='.$_GET['nday'].'&nmonth='.$_GET['nmonth'].'&nyear='.$_GET['nyear'].'\'"><br />
								<span style="font-family:arial; font-size:26px"><b>Table '.$table.'</b></span><br />
								<span style="font-family:arial; font-size:16px"><b>'.$time.'</b></span><br>
								<span style="font-family:arial; font-size:16px"><b>'.$ncust.' persons</b></span>
							</div>
						';	
                    }	  
                    ?>                  
                  </div>  
                </td>
            </tr>
        </table>
     </td>
</tr>
<!--footer-->
<tr>
	<td style="width:100%;"><table style="width:100%; height:100%">
		<tr>
			<td style="width:50%;"><img alt="" src="../images/spacer.gif" width="1" height="1"></td>
			<td style="width:766px;"><table style="width:766px;">
				<tr><td class="end"><table>
					
				</table></td></tr>
				<tr>
				  <td class="end">&nbsp;</td>
			  </tr>
			</table></td>
			<td style="width:50%;"><img alt="" src="../images/spacer.gif" width="1" height="1"></td>
		</tr>
	</table></td>
</tr>
</table>
</body>
</html>
